package com.matchmealpha;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.BaseAdapter;


public class RecentListAdapter extends BaseAdapter  {
	private Context context;
	private List<Post> recentList;
	private int selectedPosition;
	private int callerID;
	
	public RecentListAdapter(Context context, List<Post> recentList, int callerID) {
		this.context = context;
		this.recentList = recentList;
		this.selectedPosition = Adapter.NO_SELECTION;
		this.callerID = callerID;
	}
	
	public int getSelectedPosition(){
		return this.selectedPosition;
	}
	@Override
	public int getCount() {
		return this.recentList.size();
	}

	@Override
	public Object getItem(int position) {
		return this.recentList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return  this.recentList.get(position).getPostID();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if ( convertView != null ){
			((RecentView)convertView).setRecentItem(this.recentList.get(position));
		}
		else {
			convertView = new RecentView(context,recentList.get(position),this.callerID);
		}
		this.selectedPosition = position;
		return convertView;
	}


}
